<template>
  <div>
    <TableForm ref="Table"></TableForm>
    <div class="btn-group">
      <el-button type="primary" @click="submit">提交</el-button>
    </div>
  </div>
</template>

<script setup lang="ts">
const Table = ref<any>(null)
provide('initiator', {
  createUser: '张三',
  createDept: '部门',
  createTime: '2024-02-27 13:58:58'
})
onMounted(() => {
  // 初始化流程
  const flowJSON = localStorage.getItem('flow') || '{}'
  const flowValueJSON = localStorage.getItem('flow-value') || '[]'
  const flow = JSON.parse(flowJSON)
  const flowValue = JSON.parse(flowValueJSON)
  Table.value?.init(flow.tableForm, flowValue)
  setTimeout(() => {
    Table.value?.setValue(flowValue)
  }, 1000)
})
const submit = () => {
  const value = Table.value.getValue()
  localStorage.setItem('flow-value', JSON.stringify(value))
}
</script>

<style lang="scss" scoped>
.btn-group {
  display: flex;
  justify-content: center;
  margin: 50px auto;
  button {
    width: 200px;
    height: 40px;
    font-size: 16px;
  }
}
</style>
